package com.ws.q1.mapper;

import com.ws.q1.bean.HouTai;
import com.ws.q1.bean.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface HoutaiMapper {


 @Select("select * from htyonghu where name=#{name} and pass=#{pass}")
 HouTai houtailogin(@Param("name") String name, @Param("pass") String pass);

 @Select("SELECT COUNT(*) FROM htyonghu WHERE name = #{name}")
 int isUsernameExists(@Param("name") String name);

 @Insert("INSERT INTO htyonghu(name, pass, tou) VALUES (#{name}, #{pass}, #{tou})")
 int add(@Param("name") String name, @Param("pass") String pass, @Param("tou") String tou);


 @Select("SELECT * FROM htyonghu WHERE name LIKE CONCAT('%', #{name}, '%')")
 List<HouTai> getUsersByName(@Param("name") String name);

 @Select("SELECT * FROM htyonghu")
 List<HouTai> getAllUsers();

 @Delete("DELETE FROM htyonghu WHERE id = #{id}")
 void deleteById(@Param("id") Integer id);

 @Select("SELECT * FROM htyonghu WHERE id = #{id}")
 HouTai huixian(@Param("id") Integer id);

 @Update("UPDATE htyonghu SET name = #{houtai.name}, pass = #{houtai.pass},tou = #{houtai.tou} WHERE id = #{id}")
 void update(@Param("id") Integer id, @Param("houtai") HouTai houtai);
}
